import { useUserStore } from "@/store/user";
import router from "@/router";
export function logout(before?: () => void, after?: () => void) {
  before && before();
  const userStore = useUserStore();
  //1.删除token
  localStorage.removeItem("token");
  //2.清除动态路由
  userStore.routes.forEach((item) => router.removeRoute(item.name));
  //3.清除pinia
  userStore.username = "";
  userStore.menus = [];
  //4.跳转登录页
  router.push("/login");
  after && after();
}
